﻿#if UNITY_EDITOR
/// <summary>
/// 编译写入块分类
/// </summary>
public enum enESF_CompilerWriteBlockClassify
{
    /// <summary>
    /// 代码块
    /// </summary>
    [ESF_AliasTooltip("代码块")]
    CodeBlock,
    /// <summary>
    /// 文本块
    /// </summary>
    [ESF_AliasTooltip("文本块")]
    TextBlock,
}
/// <summary>
/// 编译写入块语法规则
/// </summary>
public enum enESF_CompilerWriteBlockSyntax
{
    /// <summary>
    /// 执行代码
    /// </summary>
    [ESF_AliasTooltip("执行代码")]
    ExecuteCode,
    /// <summary>
    /// 等号赋值
    /// </summary>
    [ESF_AliasTooltip("等号赋值")]
    EqualSignSssignment,
    /// <summary>
    /// 内联函数
    /// </summary>
    [ESF_AliasTooltip("内联函数")]
    InlineFunction,
    /// <summary>
    /// using引用
    /// </summary>
    [ESF_AliasTooltip("using引用")]
    Using,
}
/// <summary>
/// 写入块
/// </summary>
public abstract class AbsESF_WriteBlock
{
    /// <summary>
    /// 构造函数
    /// </summary>
    /// <param name="_originBlock">原始代码块</param>
    public AbsESF_WriteBlock(string _originBlock)
    {
        originBlock = _originBlock;
    }    
    /// <summary>
    /// 原始代码块
    /// </summary>
    public string originBlock { get; private set; }    
    /// <summary>
    /// 块分类
    /// </summary>
    public virtual enESF_CompilerWriteBlockClassify classify { get { return enESF_CompilerWriteBlockClassify.TextBlock; } }
    /// <summary>
    /// 语法规则
    /// </summary>
    public virtual enESF_CompilerWriteBlockSyntax syntax { get { return enESF_CompilerWriteBlockSyntax.ExecuteCode; } }
    /// <summary>
    /// 结果代码块
    /// </summary>
    string mResultBlock = string.Empty;
    /// <summary>
    /// 解析
    /// </summary>
    public void Resolver()
    {
        mResultBlock = OnResolver(originBlock);
    }
    /// <summary>
    /// 解析
    /// </summary>
    /// <param name="_originBlock">原始代码块</param>
    /// <returns>解析的代码块</returns>
    protected virtual string OnResolver(string _originBlock) { return _originBlock; }
    /// <summary>
    /// 获得代码块
    /// </summary>
    /// <returns>代码块</returns>
    public string GetCode()
    {
        return OnGetCode(mResultBlock);
    }
    /// <summary>
    /// 获得代码块
    /// </summary>
    /// <param name="_resultCodeBlock">结果代码块</param>
    /// <returns>代码块</returns>
    protected virtual string OnGetCode(string _resultCodeBlock) { return _resultCodeBlock; }
}
#endif